<?php 
	function HammingDis($x,$y){
		$result = 0;
		$decX = decbin($x);
		$decY = decbin($y);
		// $strlen = (int)strlen($decX)>(int)strlen($decY) ? (int)strlen($decX) : (int)strlen($decY);
		if ((int)strlen($decX)>(int)strlen($decY) ) {
			$strlen = (int)strlen($decX);
			$zero = (int)strlen($decX)-(int)strlen($decY);
			for ($i=0; $i <$zero ; $i++) { 
				$decY = '0'.$decY;
			}
		}else{
			$strlen = (int)strlen($decY);
			$zero = (int)strlen($decY)-(int)strlen($decX);
			for ($i=0; $i <$zero ; $i++) { 
				$decX = '0'.$decX;
			}
		}

		for ($i=0; $i <$strlen ; $i++) { 
			if (substr($decX,$i,1)!=substr($decY,$i,1)) {
				$result++;
			}
		}

		return $result;
		// var_dump('decX:'.$decX);
		// echo '<br/>';
		// var_dump('decY:'.$decY);
	}

	var_dump(HammingDis(1,4));

	/**
	 两个整数之间的汉明距离是职位的相应位的数量是不同的。

给定两个整数x和y,计算汉明距离。

注意:
0≤x,y < 2 ^ 31。

例子:

输入:x = 1,y = 4

输出:2

解释:
1 =(0 0 0 1)
4 =(0 1 0 0)

第二和第四的位置对应的位是不同的。

请写一个函数,输入参数和返回结果。
	 */

/**
 There is a table World

+-----------------+------------+------------+--------------+---------------+
| name            | continent  | area       | population   | gdp           |
+-----------------+------------+------------+--------------+---------------+
| Afghanistan     | Asia       | 652230     | 25500100     | 20343000      |
| Albania         | Europe     | 28748      | 2831741      | 12960000      |
| Algeria         | Africa     | 2381741    | 37100000     | 188681000     |
| Andorra         | Europe     | 468        | 78115        | 3712000       |
| Angola          | Africa     | 1246700    | 20609294     | 100990000     |
+-----------------+------------+------------+--------------+---------------+
A country is big if it has an area of bigger than 3 million square km or a population of more than 25 million.

Write a SQL solution to output big countries' name, population and area.

For example, according to the above table, we should output:

+--------------+-------------+--------------+
| name         | population  | area         |
+--------------+-------------+--------------+
| Afghanistan  | 25500100    | 652230       |
| Algeria      | 37100000    | 2381741      |
+--------------+-------------+--------------+
 */
 ?>
